package com.google.code.virtualhockey.vhx.client.vp;

import com.google.code.virtualhockey.vhx.client.VhxEntryPoint;
import com.google.code.virtualhockey.vhx.client.VhxEventBus;
import com.google.code.virtualhockey.vhx.client.model.JsNameValuePair;
import com.google.code.virtualhockey.vhx.client.srvcom.Command;
import com.google.code.virtualhockey.vhx.client.srvcom.CommandCallback;
import com.google.gwt.core.client.JsArray;
import com.mvp4g.client.annotation.Presenter;
import com.mvp4g.client.presenter.BasePresenter;

/** Presenter for the ContentView. */
@Presenter( view = ContentView.class )
public class ContentPresenter extends BasePresenter<ContentView, VhxEventBus> {

  public void onStart(){
    // does nothing, here to force view instantiation before injection into other UI parts

    VhxEntryPoint.dispatcher().dispatch( new Command( "GetServerEnv" ), new CommandCallback<JsArray<JsNameValuePair>>() {
      @Override
      public void handle( JsArray<JsNameValuePair> result ) {
        getView().setProperties( result );
      }
    } );
  }
}
